import request from '@/utils/request'

export type SupervisionVO = {
  id: number
  supName: string
  typeId: number
  typeName: string
  leaderId: number
  leaderName: string
  managerId: number
  creatorId: number
  creatorName: string
  managerName: string
  endTime: string
  beginTime: string
  content: string
  status: number
  parentId: number
  realEndTime: string
  userId: number
  userName: string
  createTime: string
  remark: string
  supId: number
  url: string
}

// 获得角色分表
export const getUserList = async (params: any) => {
  return await request.get({ url: '/system/user/page', params })
}

// 获得角色详细信息
export const getUser = async (id: number) => {
  return await request.get({ url: '/system/user/get?id=' + id })
}

export const SupervisionApi = {
  /* 督办接口 */
  // 获得督办分表
  getSupervisionList: async (params: any) => {
    return await request.get({ url: '/system/supervision/page', params })
  },

  // 获得督办信息
  getSupervision: async (id: number) => {
    return await request.get({ url: '/system/supervision/get?id=' + id })
  },

  // 创建督办
  createSupervision: async (data: SupervisionVO) => {
    return await request.post({ url: '/system/supervision/create', data: data })
  },

  // 更新督办
  putSupervision: async (data: SupervisionVO) => {
    return await request.put({ url: '/system/supervision/update', data })
  },

  //删除督办
  deleteSupervision: async (id: number) => {
    return await request.delete({ url: '/system/supervision/delete?id=' + id })
  },

  /* 分类接口 */
  //创建分类
  createSupervisionType: async (data: { typeName: string }) => {
    return await request.post({ url: '/system/supervision-type/create', data })
  },

  //删除分类
  deleteSupervisionType: async (id: number) => {
    return await request.delete({ url: '/system/supervision-type/delete?id=' + id })
  },

  //获得分类详情
  getSupervisionType: async (id: number) => {
    return await request.get({ url: '/system/supervision-type/get?id=' + id })
  },

  ///获得分类分表
  getSupervisionTypeList: async (params: any) => {
    return await request.get({ url: '/system/supervision-type/page', params })
  },

  //更新分类
  putSupervisionType: async (data: { id: number; typeName: string }) => {
    return await request.put({ url: '/system/supervision-type/update', data })
  },

  /* 申请接口 */
  //创建申请
  createSupervisionApply: async (data: { supId: number; content: string }) => {
    return await request.post({ url: '/system/supervision-apply/create', data })
  },

  //删除申请
  deleteSupervisionApply: async (id: number) => {
    return await request.delete({ url: '/system/supervision-apply/delete?id=' + id })
  },

  //获得申请详情
  getSupervisionApply: async (id: number) => {
    return await request.get({ url: '/system/supervision-apply/get?id=' + id })
  },

  //获得申请分表
  getSupervisionApplyList: async (params: any) => {
    return await request.get({ url: '/system/supervision-apply/page', params })
  },

  //更新申请
  putSupervisionApply: async (data: { id: number; supId: number; content: string }) => {
    return await request.put({ url: '/system/supervision-apply/update', data })
  },

  // 发送催办
  sendSupervisionApply: async ( data: { supId: number; content: string,url:string,supName:string,creator?:string }) => {
    return await request.post({  url: '/system/supervision-info/create', data })
  },

  //获取子表评论
  getSupervisionInfoList: async (params: any) => {
    return await request.get({ url: '/system/supervision-info/page', params })
  },

  // 回复督办（针对子表记录）
  replySupervisionInfo: async (data: { id: number; replyContent: string; url?: string }) => {
    return await request.post({ url: '/system/supervision-info/reply', data })
  }
}
